package net.hn.hnms.biz.common.activiti.builder;

import cn.hutool.core.collection.CollUtil;
import org.activiti.bpmn.model.UserTask;

import java.util.List;

/**
 * Created on 2022/8/4.
 *
 * @author ly
 * @desc: 用户流程任务创建器
 */
public class UserTaskCreator {

    UserTask userTask = new UserTask();

    public UserTaskCreator id(String id) {
        userTask.setId(id);
        return this;
    }

    //流程任务名称
    public UserTaskCreator name(String name) {
        userTask.setName(name);
        return this;
    }

    //执行流程任务所需人员
    public UserTaskCreator requiredUsers(List<String> values) {
        if (CollUtil.isNotEmpty(values)) {
            userTask.setCandidateUsers(values);
        }
        return this;
    }

    //执行流程任务所需角色
    public UserTaskCreator requiredRoles(List<String> values) {
        if (CollUtil.isNotEmpty(values)) {
            userTask.setCandidateGroups(values);
        }
        return this;
    }

    //流程任务受让人
    public UserTaskCreator assignee(String assignee) {
        userTask.setAssignee(assignee);
        return this;
    }

    public UserTask build() {
        return userTask;
    }

}
